/**
 * 排班管理相关API
 */
import request from '../../utils/request'

interface Event {
  id?: string;
  title: string;
  technician: string;
  start: Date | string;
  end: Date | string;
  color?: string;
  notes?: string;
}

interface OptimizationParams {
  start?: string;
  end?: string;
}

// 获取员工列表
export function getTechnicians() {
  return request({
    url: '/api/schedules/technicians',
    method: 'get'
  })
}

// 获取排班事件
export function getEvents(params: { start?: string; end?: string }) {
  return request({
    url: '/api/schedules/events',
    method: 'get',
    params
  })
}

// 创建排班事件
export function createEvent(data: Event) {
  return request({
    url: '/api/schedules/events',
    method: 'post',
    data
  })
}

// 更新排班事件
export function updateEvent(id: string, data: Event) {
  return request({
    url: `/api/schedules/events/${id}`,
    method: 'put',
    data
  })
}

// 删除排班事件
export function deleteEvent(id: string) {
  return request({
    url: `/api/schedules/events/${id}`,
    method: 'delete'
  })
}

// 获取资源优化建议
export function getOptimizationSuggestions(params: OptimizationParams) {
  return request({
    url: '/api/schedules/optimization-suggestions',
    method: 'get',
    params
  })
}